﻿<%@ Page Title="个人宽带电子工单" Language="C#" MasterPageFile="~/Site.master" CodeBehind="ADSLFTTPFTTH.aspx.cs" Inherits="Com.Crc.WorkFormManage.Web.ADSLFTTPFTTH.ADSLFTTPFTTH" %>

<%@ Register Assembly="Infragistics2.WebUI.UltraWebGrid.v7.2, Version=7.2.20072.61, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.WebUI.UltraWebGrid" TagPrefix="igtbl" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript" src="/Theme/jquery-1.7.1.js"></script>
    <script type="text/javascript" src="/Theme/jquery.json-2.3.min.js"></script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

<table id="workform_table" border="1">
            <tr>
                <td colspan="4" id="msgbox" style="">
                    
                </td>
            </tr>   
            <tr>
                <td>工单类型:</td>
                <td>
                    <asp:RadioButton ID="newInstal_type"  Text="新装" GroupName="worformtype"   runat="server" />
                    <asp:RadioButton ID="modify_type" Text="修改" GroupName="worformtype" runat="server" />
                    <asp:RadioButton ID="eplan_type" Text="改E计划(融合套餐)"  GroupName="worformtype" runat="server" />
                    <asp:RadioButton ID="unInstall_type" Text="拆除" GroupName="worformtype" runat="server" />
                </td>
            </tr>                        
            <tr>
                <td>
                    <asp:Label ID="Label3" Text="接入方式" runat="server" /> 
                </td>
                <td>
                    <asp:RadioButton ID="adsl" GroupName="intype"  Text="ADSL宽带" runat="server" />
                    <asp:RadioButton ID="epon" GroupName="intype"  Text="EPON宽带" runat="server" />
                </td>
            </tr>
            <tr id="newInstal_type_e_tr" style="display:none">
                <td align="center" >
                    <span id="title_e_n" style="display:none"  >
                            新装<br/>
                            [EPON]<br/>
                            均为必填项
                    </span>
                    <span  id="title_a_n" style="display:none">
                            新装<br/>
                            [ADSL]<br/>
                            均为必填项
                    </span>
                </td>
                <td colspan="2" align="left">
                    
                    <table border="1">
                        <tr id="ddlOffice_a_n" style="display:none">
                            <td>
                                <asp:Label ID="lbintypeddlOffice_a_n" runat="server" Text="接入局点"></asp:Label>
                            </td>
                                <td>
                                    <asp:DropDownList
                                                ID="intypeddlOffice_a_n" runat="server" Width="100px">
                                    </asp:DropDownList>
                                </td>
                        </tr>
                        <tr id="xincun_e_n" style="display:none">
                            <td>
                                <asp:Label ID="lbXincun_e_n" Text="接入新村" runat="server"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList
                                                ID="inXincun_e_n" runat="server" Width="100px">
                                </asp:DropDownList> 
                            </td>
                            <td colspan="2">
                                <asp:CheckBox ID="isGaizhuangEPON_e_n" runat="server" Text="老用户改装EPON" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lbname_e_n" runat="server" Text="用户账号(原)"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="account_e_n" runat="server"></asp:TextBox>
                            </td>
                            <td colspan="3">
                                <span id="readAccountInfo_span" style="display:none">
                                    <input type="button" value="读取用户信息" onclick="return showAccountInfo('account_e_n');" />
                                </span>
                            </td>
                        </tr>
                        <tr id="newname_info" style="display:none">
                            <td>
                                <asp:Label ID="lbnewname_e_n" runat="server" Text="新的账号"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="newaccount_e_n" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        
                        <tr>
                            <td>
                                <asp:Label ID="Label6" runat="server" Text="用户带宽"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList
                                                ID="account_daikuan_e_n" runat="server" Width="100px">
                                </asp:DropDownList> 
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lbaccountname_e_n" runat="server" Text="用户姓名"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="accountname_e_n" runat="server" ></asp:TextBox>
                            </td>
                            <td>
                                <asp:Label ID="lbaccountphone_e_n" runat="server" Text="联系电话"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="accountPhone_e_n" runat="server" ></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="lbaddresstype_e_n" runat="server" Text="地址类型" ></asp:Label>
                            </td>
                            <td>
                                 <asp:DropDownList
                                            ID="addresstype_e_n" runat="server">
                                </asp:DropDownList> 
                            </td>
                            <td>
                                <asp:Label ID="lbaddress_e_n" runat="server" Text="用户地址"></asp:Label>
                            </td>
                            <td>
                                <table>
                                <tr>
                                    <td>
                                    <asp:DropDownList
                                                ID="AREA_SHI" runat="server" >
                                                    <asp:ListItem Value='-1' Text="市"></asp:ListItem>
                                    </asp:DropDownList></td>
                                    <td><asp:DropDownList
                                                ID="AREA_QU" runat="server" >
                                                <asp:ListItem Value='-1' Text="区"></asp:ListItem>
                                    </asp:DropDownList></td>
                                    <!--<td><asp:DropDownList
                                                ID="AREA_ZHENG" runat="server">
                                                <asp:ListItem Value='-1' Text="镇"></asp:ListItem>
                                    </asp:DropDownList></td>
                                    <td><asp:DropDownList
                                                ID="AREA_CUN" runat="server">
                                                <asp:ListItem Value='-1' Text="村"></asp:ListItem>
                                    </asp:DropDownList></td>
                                    <td><asp:DropDownList
                                                ID="AREA_ZU" runat="server">
                                                <asp:ListItem Value='-1' Text="组"></asp:ListItem>
                                    </asp:DropDownList></td>
                                    -->
                                    <td><asp:DropDownList
                                                ID="AREA_LU" runat="server">
                                                <asp:ListItem Value='-1' Text="路"></asp:ListItem>
                                    </asp:DropDownList>
                                    </td>
                                    <td><asp:DropDownList
                                                ID="AREA_SUBDISTICT" runat="server">
                                                <asp:ListItem Value='-1' Text="小区名"></asp:ListItem>
                                    </asp:DropDownList></td>
                                    <td>
                                    <span id="span_addres_e_n" style="display:none">
                                    <asp:TextBox ID="address_e_n" runat="server" Text=""></asp:TextBox>
                                    </span>
                                    <span id="span_address_unit" style="display:inline">
                                    <asp:DropDownList
                                                ID="ADDRESS_UNIT" runat="server">
                                                <asp:ListItem Value='-1' Text="楼号选择"></asp:ListItem>
                                    </asp:DropDownList>
                                    </span>
                                    </td>
                                </tr>
                                </table>
                            </td>
                        </tr>
                        <tr id="oun_e_n" style="display:none">
                            <td>
                                <asp:Label ID="lboun" runat="server" Text="选择OUN"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList
                                            ID="dropdownoun_e_n" runat="server" Width="100px">
                                </asp:DropDownList> 
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                 <asp:Button ID="Button1" runat="server" Text="保存转交" CssClass="inputbutton" onclick="newInstall"/>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="center">
                    工单备注
                </td>
                <td colspan="2" align="left">
                    <table>
                        <tr>
                            <td colspan="4">
                                <asp:TextBox ID="bak"  runat="server" Columns="5" Rows="3" MaxLength="50" 
                                    Height="67px" Width="438px" ></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>


</table>

<script type="text/javascript">

    function showSelectONU(clickObj, type) {
        var selectText = $('#MainContent_' + clickObj).find("option:selected").text();  
        if (selectText == type) {

            $('#span_addres_e_n').attr("style", "display:inline");
            $('#span_address_unit').attr("style", "display:none");

            $.each($("#workform_table tr"), function (i) {
                if (i > 0) {
                    if (this.id == 'oun_e_n') {
                        this.style.display = "inline";
                    }
                }
            });  

        } else {

            $('#span_addres_e_n').attr("style", "display:none");
            $('#span_address_unit').attr("style", "display:inlie");

            $.each($("#workform_table tr"), function (i) {
                if (i > 0) {
                    if (this.id == 'oun_e_n') {
                        this.style.display = "none";
                    }
                }
            });

        }
    }

    function switchSelect(type) {
        $('#title_e_n').attr("style","display:none");
        $('#title_a_n').attr("style", "display:none");
        $('#ddlOffice_a_n').attr("style", "display:none");
        $('#xincun_e_n').attr("style", "display:none");
        $('#readAccountInfo_span').attr("style", "display:none");
        $('#newname_info').attr("style", "display:none");
        
        if (type == 'newInstal_type_tr' || type == 'adsl' || type == 'epon') {

            type = "";
            var selected = $("#MainContent_epon:checked").val(); //若未被选中 则val() = null
            if (selected != null) {
                type = 'newInstal_type_e_tr';
                $('#title_e_n').attr("style", "display:inline");
                $('#xincun_e_n').attr("style", "display:inline");
            }
            selected = $("#MainContent_adsl:checked").val(); //若未被选中 则val() = null
            if (selected != null) {
                type = 'newInstal_type_e_tr';
                $('#title_a_n').attr("style", "display:inline");
                $('#ddlOffice_a_n').attr("style", "display:inline");
            }
            if (type == "") {
                alert("请选择新装类型!");
                return;
            }

            $("#MainContent_newInstal_type").attr("checked", 'checked');


        } else {
            if (type == 'eplan_type_tr') {
                $('#newname_info').attr("style", "display:inline");
            }
            $('#readAccountInfo_span').attr("style", "display:inline");
            type = 'newInstal_type_e_tr';
        }

        $.each($("#workform_table tr"), function (i) {
            if (i > 0) {
                if (this.id.indexOf("_tr") >= 0) {
                    if (this.id.indexOf(type) >= 0) {
                        this.style.display = "inline";
                    } else {
                        this.style.display = "none";
                    }
                }
            }
        }); 
    }


        function showNexeInfo(change) {
            var selectValue = $('#MainContent_' + change).find("option:selected").val();
            if (change == 'AREA_QU') {
                showNextSelect('AREA_LU', selectValue);
            } 
            if (change == 'AREA_LU') {
                showNextSelect('AREA_SUBDISTICT', selectValue);
            }
            if (change == 'AREA_SUBDISTICT') {
                showNextSelect('ADDRESS_UNIT', selectValue);
            }
        }
        function showNextSelect(change, selectValue) {
            var parentId = selectValue.split("|")[0];
            var sonId = selectValue.split("|")[1];
            var selfId = selectValue.split("|")[2];
            showNext(change, selfId);
        }
        function showNext(change, parentId) {
            $('#MainContent_' + change).each(function () {
                $(this).children("span").each(function () {
                    if ($(this).id != 'span_addres_e_n' || $(this).id != 'span_address_unit') {
                        $(this).children("option").each(function () {
                            $(this).unwrap();
                        });
                    }
                });
            });
            $('#MainContent_' + change).each(function () {
                $(this).children("option").each(function () {


                    var selectText = $('#MainContent_addresstype_e_n').find("option:selected").text();
                    if (selectText != '标准地址' && change == 'ADDRESS_UNIT') {
                        return;
                    }


                    var parentId1 = $(this).val().split("|")[0];
                    var sonId1 = $(this).val().split("|")[1];
                    var selfId1 = $(this).val().split("|")[2];

                    if (parentId1 != parentId) {
                        $(this).wrap("<span id='span_" + parentId1 + "' style='display:none'></span>")
                    }
                });
            });
        }

        function showUpSelect(change, selectValue) {
            var parentId = selectValue.split("|")[0];
            var sonId = selectValue.split("|")[1];
            var selfId = selectValue.split("|")[2];

            if (change == 'AREA_LU') {
                showUp('AREA_QU', parentId)
            }
            if (change == 'AREA_QU') {
                showUp('AREA_SHI', selfId);
            }
        }
        function showall(change) {
            $('#MainContent_' + change).each(function () {
                $(this).children("span").each(function () {
                    $(this).children("option").each(function () {
                        $(this).unwrap();
                    });
                });
            });
        }
        function showSelf(change, currValue) {
            showall(change);
            $('#MainContent_' + change).each(function () {
                $(this).children("option").each(function () {
                    if ($(this).val() == currValue) {
                        $(this).attr('selected', 'selected');
                        return;
                    }
                });
            });
        }
        function showUp(change, currId) {
            showall(change);
            $('#MainContent_' + change).each(function () {
                $(this).children("option").each(function () {
                    var parentId1 = $(this).val().split("|")[0];
                    var sonId1 = $(this).val().split("|")[1];
                    var selfId1 = $(this).val().split("|")[2];

                    if (selfId1 == currId) {
                        $(this).attr('selected', 'selected');
                        showUpSelect(change, parentId1);
                    }
                });
            });
        }

        function showAccountInfo(accountId) {
            var info = $('#MainContent_' + accountId).val();
            $.ajax({
                type: "GET",
                cache: "false",
                contentType: 'text/json',
                url: "ADSLFTTPFTTH.aspx?action=showAccountInfo",
                data: "account=" + info + "&r=" + Math.random(),
                dataType: "json",
                success: function (msg) {
                    if (msg.msgcode != 1) {
                        alert(msg.msginfo);
                        return;
                    }

                    $('#MainContent_account_daikuan_e_n').val(msg.msginfo.s_DK);
                    $('#MainContent_accountname_e_n').val(msg.msginfo.s_NAME);
                    $('#MainContent_accountPhone_e_n').val(msg.msginfo.s_TEL);

                    var upId = msg.msginfo.s_AREA_ID_INFO;
                    var subdistict = msg.msginfo.n_IN_AREA;
                    showUpSelect('AREA_LU', upId);
                    showall('AREA_LU');

                    $('#MainContent_AREA_LU').val(upId);
                    $('#MainContent_AREA_SUBDISTICT').val(subdistict);
                    $('#MainContent_addresstype_e_n').val(msg.msginfo.s_ADDRESS_TYPE);

                    $('#MainContent_AREA_SUBDISTICT').each(function () {
                        $(this).children("option").each(function () {
                            var parentId1 = $(this).val().split('|')[$(this).val().split('|').length-1];
                            if (parentId1 == subdistict) {
                                $(this).attr('selected', 'selected');
                            }
                        });
                    });

                    if (msg.msginfo.s_ADDRESS_TYPE == '3') {
                        $('#span_addres_e_n').attr("style", "display:none");
                        $('#span_address_unit').attr("style", "display:inline");


                        $('#MainContent_ADDRESS_UNIT').each(function () {
                            $(this).children("option").each(function () {
                                var parentId1 = $(this).val();

                                if (parentId1 == msg.msginfo.s_ADDRESS) {
                                    $(this).attr('selected', 'selected');
                                }
                            });
                        });
                    } else {
                        $('#span_addres_e_n').attr("style", "display:inline");
                        $('#span_address_unit').attr("style", "display:none");
                        $('#MainContent_address_e_n').val(msg.msginfo.s_ADDRESS);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("调用服务接口失败，如果多次重试后仍然有错误，请即可通知管理员" + "[" + textStatus + "]" + "[" + errorThrown + "]");
                }

            });
        }

        try {
            if (selecttype != null)
                switchSelect(selecttype);

            if (msg != null) {

                var encoded = eval("(" + msg + ")");
                // '{"plugin":"jquery-json","version":2.3}'
                //var jsonEncode = $.evalJSON(encoded);
                var msgCode = encoded.msgCode;
                // "jquery-json"
                var msgInfo = encoded.msgInfo;
                // 2.3
                if (msgCode == 1) {
                    $("#msgbox").attr("style", "color:Green");
                } else {
                    $("#msgbox").attr("style", "color:Red");
                }

                $("#msgbox").text(msgInfo);

            } else {
                $("#msgbox").attr("style", "");
                $("#msgbox").text("");
            }
        } catch (e) { }

</script>
</asp:Content>